//
// Description: 913. 排队打水
// Created by Loading on 2022/6/5.
//

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

constexpr int N = 1e5 + 10;

int t[N];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
    }

    sort(t, t + n);

    LL res = 0;
    for (int i = 0; i < n; ++i) {
        res += t[i] * (n - i - 1);
    }

    cout << res << endl;

    return 0;
}